package com.topInterview;

/**
 * @Author: huangzhigao
 * @Date: 2022/2/19 16:14
 */
public class Leecode26_removeRepeatNum {
    public int removeDuplicates(int[] nums) {
        if (nums == null || nums.length < 1) {
            return 0;
        }

        if (nums.length < 2) {
            return nums.length;
        }

        int index = 0;
        nums[index++] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[i - 1]) {
                nums[index++] = nums[i];
            }
        }
        return index;
    }
}
